#{extends 'main.html' /}

<script type="text/javascript">
$(document).ready(function() { 		$('.functionalties').hide('slow');
 });
	function getTagstarek(search) {
		if (search != "") {
			$(function() {
				$.getJSON('@{QuickSearchRendering.autoComplete1()}', {
					'search' : search
				}, function(data) {
					$("#usertoinvite").autocomplete({
						source : data.tags.split("&")
					});
				});

			});
		}
	}
	function inn() {
		$.getJSON(

		'@{Application.requestIdeaDeveloperToOrganization()}',

		{
			'devName' : document.getElementById("usertoinvite").value,
			'orgId' : $("select[id$='mydropdown'] :selected").val(),
			'type':'JoinOrgFromOrgToDev'

		},
		function(data) {
			alert(data.res);
		}, 'json')
		$('#inviteIdeadev').hide('slow');
	}

	function blockIdeaDeveloper(){
		var reason = document.getElementById("reason").value;
		var ideaDeveloper = document.getElementById("usertoblock").value;
		if(reason.length)
		$.getJSON(

		'@{BlockIdeaDeveloper.blockFromOrganization()}',

		{
			'organizationName' : $("select[id$='mydropdown'] :selected").text(),
			'ideadeveloperName' : ideaDeveloper,
			'reason' : reason
		},
		function(data) {
			alert(data.output);
		}, 'json')
	$('#blockIdeaDeveloperDiv').hide('slow');
	}
	function unblockIdeaDeveloper(){
			$.getJSON(

		'@{BlockIdeaDeveloper.unblockFromOrganization()}',

		{
			'organizationName' : $("select[id$='mydropdown'] :selected").text(),
			'ideadeveloperName' : document.getElementById("usertoblock").value,
			'reason' :document.getElementById("reason").value
		},
		function(data) {
			alert(data.output);
		}, 'json')
	$('#blockIdeaDeveloperDiv').hide('slow');
	}
</script>

<h1>Hello ${loggedInUserName}</h1>
<h2>What can you do ?</h2>
<ul>
	<li><a href="#" id="invite_buttton"
		onclick="javascript:$('#inviteIdeadev').toggle();">Invite
			Idea-developer to Join you Organization !</a>
	</li>

	<li><a  href="#" id="edit_profile" onclick="javascript:$('#editCompanyProfile').toggle();">Edit
			company profile</a>
	</li>
	<li><a  href="#" id="block" onclick="javascript:$('#blockIdeaDeveloperDiv').toggle();">Block Idea developer</a>
	</li>

</ul>

<div id="inviteIdeadev" class="functionalties">

	<select name="mydropdown" id="mydropdown">
	#{list items:organizations, as: 'organization' }
		<option id="${organization.id}" value="${organization.id}">${organization.name}</option>
	</select> #{/list}
	<p>

		Invite: <input type="text" id="usertoinvite"
			onkeyup="javascript:getTagstarek(document.getElementById('usertoinvite').value);" />
	</p>
	<p>
		<a href="#" id="invite_buttton" onclick="inn()">Invite !</a>
	</p>

</div>

<div id="editCompanyProfile" class="functionalties">
	choose organiztion to change profile :
		<ul>
		#{list items:organizations, as: 'organization' }
		<li ><a class="frame" id="chosen"
		href="@{OrganizationLeadFunctionalities.editOrganizationProfile(organization.name)}" id="${organization.id}" >${organization.name} </a></li>
	</ul>

	#{/list}

</div>

<div id="blockIdeaDeveloperDiv" class="functionalties">


	<select name="mydropdownblock" id="mydropdownblock">
	#{list items:organizations, as: 'organization' }
		<option id="${organization.id}" value="${organization.name}">${organization.name}</option>
	</select> #{/list}
	<p>

		Block: <input type="text" id="usertoblock"/>


	</p>
	<label for="reason">
                    Reason:
                </label>
                <input name="reason" id="reason" value="" type="text" />

	<p>
		<a href="#" id="block_buttton" onclick="blockIdeaDeveloper()">Block !</a>
		<a href="#" id="unBlock_buttton" onclick="unblockIdeaDeveloper()">Unblock !</a>
	</p>

</div>